<%+header%>

<h2>
	<a id="content" name="content">客户端日志</a>
</h2>

<div class="cbi-map-descr">
</div>

<table width="100%" cellspacing="10">
	<tbody>
		<tr class="cbi-section-table-row cbi-rowstyle-1">
			<td width="33%"><strong>配置文件</strong></td>
			<td><input style="margin: 2px;" class="cbi-button cbi-button-apply" type="button" value="打包下载" onclick='window.open("<%=luci.dispatcher.build_url('admin/scutclient/scutclient-log.tar')%>")'></td>
	</tbody>
</table>

<h3>
	scutclient日志
</h3>

<div id="content_logs">
	<textarea style="font-size: 12px;" readonly="readonly" wrap="off" rows="50" id="syslog">
		Collecting data...
	</textarea>
</div>

<script type="text/javascript" language="javascript">
xhrobj = new XHR();

xhr_rawget = function(url,data,callback) {
	xhrobj.reinit();
	var xhr  = xhrobj._xmlHttp;
	var code = xhrobj._encode(data);
	url = location.protocol + '//' + location.host + url;
	if (code)
		if (url.substr(url.length-1,1) == '&')
			url += code;
		else
			url += '?' + code;
	xhr.open('GET', url, true);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			callback(xhr, xhr.responseText);
		}
	}
	xhr.send(null);
}

readlog = function() {
	if(!xhrobj.busy()) {
		xhr_rawget('<%=luci.dispatcher.build_url('admin/scutclient/get_log')%>', null,
			function(x, log_data) {
				var syslog_id = document.getElementById("syslog");
				if (typeof(log_data) != "undefined") {
					syslog_id.innerHTML = log_data;
				}
				document.getElementById("syslog").scrollTop=document.getElementById("syslog").scrollHeight;
			}
		);
	}
}
readlog();
window.setInterval(readlog, 3000);
</script>

<%+footer%>
